package com.originskyseed.platform.log.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.originskyseed.platform.core.aspect.annotation.RequiredParams;
import com.originskyseed.platform.core.base.BaseController;
import com.originskyseed.platform.core.base.BaseLocaleResource;
import com.originskyseed.platform.core.base.BasePage;
import com.originskyseed.platform.core.base.BaseResponseBody;
import com.originskyseed.platform.core.common.code.CommonResponseCode;
import com.originskyseed.platform.log.i18n.LogResponseMsg;
import com.originskyseed.platform.log.model.InterfaceSynchroLog;
import com.originskyseed.platform.log.service.IInterfaceSynchroLogService;
import com.originskyseed.platform.log.vo.request.InterfaceSynchroLogRequestVO;

/**
 * @Description
 * @Author Tangwh
 * @Version V1.0
 **/
@Controller
@RequestMapping("/interfaceSynchroLog")
@BaseLocaleResource(localeFileName = "i18n_log")
public class InterfaceSynchroLogController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(InterfaceSynchroLogController.class);

	@DubboReference
	IInterfaceSynchroLogService iInterfaceSynchroLogService;

	/**
	 * 同步OA日志分页查询列表
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/interfaceSynchroLogPageList.json")
	@RequiredParams(names = { "pageNo", "pageSize" })
	public BaseResponseBody loginLogPageList(HttpServletRequest request) {
		BaseResponseBody result = null;
		try {
			// 请求对象
			InterfaceSynchroLogRequestVO requestVO = this.getParameterBean(InterfaceSynchroLogRequestVO.class);
			// 分页查询
			BasePage<InterfaceSynchroLog> page = new BasePage<InterfaceSynchroLog>(requestVO.getPageNo(), requestVO.getPageSize());
			page = this.iInterfaceSynchroLogService.selectListByPage(requestVO.toMap(), page);
			result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), LogResponseMsg.LOG_LIST_SUCCESS.getMsg()), page);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), LogResponseMsg.LOG_LIST_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

}
